import http from "@/api";
import { IPermission, IPermissionList, ListQueryParams, ISubmitPermission } from "@/api/interface/permission";

// * 获取全部菜单列表
export const getPermissionList = (params: ListQueryParams) => {
	return http.get<IPermissionList>({
		url: `/permission/getPermissionList`,
		params
	});
};

// * 获取全部菜单列表
export const getAllPermissionList = () => {
	return http.get<IPermission[]>({
		url: `/permission`
	});
};

// * 创建权限
export const createPermission = (permission: ISubmitPermission) => {
	return http.post({
		url: `/permission`,
		data: permission
	});
};

// * 修改权限
export const updatePermission = (permission: ISubmitPermission) => {
	return http.patch({
		url: `/permission/${permission.id}`,
		data: permission
	});
};

// * 删除权限
export const deletePermission = (id: number) => {
	return http.delete({
		url: `/permission/${id}`
	});
};
